<script>
    var page_list = "vipmember_list";
    $(function() {
        $("body").layout();
        grid_init($("#grid"),{
            singleSelect: false,
            url:'slave/basis/findList.do',
            columns:[[
                { field: 'o.id', checkbox: true, title: 'ID',width: 80},
                { field: 'o.name',  title: '名称',width: 80},
                { field: 'o.vip_no', title: '号码',width: 100},
                { field: 'o.mobile', title: '手机',width: 100},
                { field: 'o.phone', title: '电话',width: 120},
                { field: 'o.province', title: '省',width: 80},
                { field: 'o.city', title: '市',width: 80},
                { field: 'o.company', title: '公司',width: 100},
                { field: 'o.address', title: '地址',width: 120},
                { field: '(SELECT t.administrativeDivisionName FROM  tbadministrativedivision AS t WHERE o.area_code = t.administrativeDivisionCode)', title: '所属区域行政区划编码',width: 160},
                { field: '(SELECT COUNT(p.id) FROM pre_accept_order p WHERE p.sender_mobile = o.mobile)', title: '下单次数',width: 90},
                { field: '(SELECT COUNT(p.id) FROM pre_accept_order p WHERE p.sender_mobile = o.mobile AND p.generate_flag = 1)', title: '已转正次数',width: 100},
                { field: '(SELECT COUNT(w.with_draw_no) FROM withdraw_money_main w WHERE w.vip_no = o.mobile)', title: '取款次数',width: 90},
                {field:'o.id_front_pic',title:'身份证正面照',width:120,
                    formatter: function(value,row,index){
                        return '<a style="color:blue" href="javascript:void(0)" onclick="showPortrait(\''+value+'\')">查看</a>';
                }},
                {field:'o.id_back_pic',title:'身份证反面照',width:120,
                    formatter: function(value,row,index){
                        return '<a style="color:blue" href="javascript:void(0)" onclick="showPortrait(\''+value+'\')">查看</a>';
                }},
                {field:'o.id_hand_pic',title:'手持身份证',width:100,
                    formatter: function(value,row,index){
                        return '<a style="color:blue" href="javascript:void(0)" onclick="showPortrait(\''+value+'\')">查看</a>';
                }},
                { field: 'o.audit_status', title: '实名制状态',width: 100,formatter: function(value,row,index){
                    if (value==1){
                        return "审核通过";
                    }else if(value==2){
                        return "驳回";
                    }else{
                        return "未审核";
                    }
                }}
            ]],
            _order:"o.create_time desc",
            _append: [],//隐藏列
            _page: page_list,
            _table: "vip_members as o",
            _db:"slave",
            _notSearch : "notSearch",
            _exportTitle: false,
            _context_handle: [{
                text: "详情",
                icon: "icon-info",
                handle: function(index,row){
                    j_showWin({url:'logistics/vipmember/info.html?keyId='+this.getFieldValue(row,"o.id"),
                        title:'VIP信息',
                        iconCls: 'icon-form-info'})
                }
            },{
                text: "审核通过",
                icon: "icon-edit",
                handle: function(index,row){
                    var grid = $(this);
                    var self = this;
                    if(self.getFieldValue(row,"o.audit_status") == 1){
                        j_tip("该VIP信息已经审核通过",'error');
                    }else{
                        $.messager.confirm('系统提示', '您确认审核通过吗?', function(r){
                            if (r){
                                self.focus();
                                showLoading();
                                fy_api.ajax({
                                    url: "vipmember/getAuditStatusPass.do?_t="+new Date().getTime(),
                                    data: {"keyId":self.getFieldValue(row,"o.id")},
                                    success: function(data){
                                        hideLoading();
                                        if(isSuccess(data)){
                                            j_tip(data.msg,'success');
                                            grid.datagrid("reload");
                                        }else{
                                            $.messager.alert('系统提示',data.msg,'error',function(){
                                                self.focus();
                                            });
                                        }
                                    }
                                });
                            }else{
                                self.focus();
                            }
                        });
                    }
                }
            },{
                text: "驳回",
                icon: "icon-edit",
                handle: function(index,row){
                    var grid = $(this);
                    var self = this;
                    if(self.getFieldValue(row,"o.audit_status") == 2){
                        j_tip("该VIP信息已经驳回",'error');
                    }else{
                        $.messager.confirm('系统提示', '您确认驳回吗?', function(r){
                            if (r){
                                self.focus();
                                showLoading();
                                fy_api.ajax({
                                    url: "vipmember/getAuditStatusBh.do?_t="+new Date().getTime(),
                                    data: {"keyId":self.getFieldValue(row,"o.id")},
                                    success: function(data){
                                        hideLoading();
                                        if(isSuccess(data)){
                                            j_tip(data.msg,'success');
                                            grid.datagrid("reload");
                                        }else{
                                            $.messager.alert('系统提示',data.msg,'error',function(){
                                                self.focus();
                                            });
                                        }
                                    }
                                });
                            }else{
                                self.focus();
                            }
                        });
                    }
                }
            }],
            toolbar: '#grid_toolbar',
            searchDiv: '#grid_search'
        });

        $("#btnBatchDelete").click(function(){
            initBatchOperation(grid_get("grid"),"vipmember/batchAuditStatusPass.do","审核通过");
        })
        $("#bhDelete").click(function(){
            initBatchOperation(grid_get("grid"),"vipmember/batchAuditStatusBh.do","驳回");
        })
    });

    function showPortrait(url){
        if(undefined != url && 'undefined' != url && null != url && 'null' != url){
            $("#portrait").attr("src",url);
        }
        var winoption = {
            title:"证件照",
            collapsible:false,
            minimizable:false,
            maximizable:true,
            modal:true,
            onBeforeClose:function(){
                $("#portrait").attr("src",'');
            }
        };
        $('#win_portrait').window(winoption);
        $('#win_portrait').window('open');
    }

</script>
<style>
    .datagrid-cell, .datagrid-cell-group, .datagrid-header-rownumber, .datagrid-cell-rownumber
    {
        text-overflow: ellipsis;
    }
</style>
<div id="grid_search" data-options="region:'north',height:'auto',hideExpandTool: true,hideCollapsedContent: false,collapsedContent:function(){return '查询条件(已隐藏)'}" style="border-top:none;border-left:none;border-right:none;" class="search-form">
    <!--<input type="hidden" name="o.deleteFlag" value="0"/>-->
    <div class="div-item">
        <div class="div-label">名称：</div>
        <input name="o.name" type="text" clear/>
    </div>
    <div class="div-item">
        <div class="div-label">手机：</div>
        <input name="o.mobile" nolike type="text" clear/>
    </div>
    <div class="div-item">
        <div class="div-label" style="width: 80px;">实名制状态：</div>
        <select name="o.audit_status" id="auditStatus" style="width: 120px;" value="${vipAuditStatus}" clear>
            <option value="" >所有</option>
            <option value="1" >审核通过</option>
            <option value="2" >驳回</option>
            <option value="_EXT_SEARCH##is null##0" >未审核</option>
            <!--_EXT_SEARCH##is null 等同于sql增加 and (col is null)条件-->
            <!--_EXT_SEARCH##is null##0 等同于sql增加 and (col is null or col = 0)条件-->
        </select>
    </div>

</div>
<div data-options="region:'center',title:false,border:false" id="divCenter" style="">
    <table id="grid"></table>
</div>
<div id="grid_toolbar" style="padding:3px;">
    <a href="javascript:void(0)" class="easyui-linkbutton <!--auth-button-->" action="delete" data-options="plain:true,iconCls:'icon-ok'" id="btnBatchDelete">批量审核</a>
    <a href="javascript:void(0)" class="easyui-linkbutton <!--auth-button-->" action="delete" data-options="plain:true,iconCls:'icon-undo'" id="bhDelete">批量驳回</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true,iconCls:'layout-button-up'" onclick="var button=$(this);if(button.linkbutton('options').iconCls=='layout-button-up'){$('body').layout('collapse','north');button.linkbutton({iconCls:'layout-button-down'})}else{$('body').layout('expand','north');button.linkbutton({iconCls:'layout-button-up'})}button.linkbutton('disable');setTimeout(function(){button.linkbutton('enable');},200)" style="float:right"></a>
    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-help'" id="help" style="float:right"></a>
    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-button-refresh'" onclick="grid_get('grid')[0].search(true)" style="float:right">重置</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-search'" onclick="grid_get('grid')[0].search()" style="float:right">查询</a>
</div>
<div id="win_portrait" class="easyui-window" closed="true" style="width:800px;height:600px;">
    <img id="portrait" src="" style="width: 95%;height: 90%" alt="未发现证件照" title="证件照"/>
</div>